<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>添加员工</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/layuiadmin/layui/css/layui.css" media="all">
</head>
<body >
<div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">
    <input hidden name="id" id="id" value="${s.id}">

    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" id="name" name="name"  lay-verify="required" value="${s.name}" placeholder="姓名"  class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">学号</label>
        <div class="layui-input-inline">
            <input type="text" id="no" disabled  lay-verify="required"  name="no" value="${s.studentNo}"  placeholder="学号"  class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">email</label>
        <div class="layui-input-inline">
            <input type="text" id="email"  name="email" value="${s.eMail}"  placeholder="请输入邮箱"  class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="text" id="phone" name="phone" value="${s.moblephone}" placeholder="请输入手机号"   class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="男" title="男" <c:if test="${s.gender=='男'}">checked</c:if>>
            <input type="radio" name="sex" value="女" title="女" <c:if test="${s.gender=='女'}">checked</c:if>>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="LAY-user-role-submit" id="subBtn">提交</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    var $;
    layui.use(['layer', 'form','element','jquery'], function(){
        var layer = layui.layer,
            form = layui.form;
        $ = layui.jquery;
        element = layui.element;
        //监听提交
        form.on('submit(LAY-user-role-submit)', function(data){

            var id=$('#id').val();
            var name=$('#name').val();
            var no=$('#no').val();
            var email=$('#email').val();
            var phone=$('#phone').val();
            var gender=$("input[name='sex']:checked").val();
            $.ajax({
                type: "post",
                url: "<%=request.getContextPath()%>/student/update",
                data: {"id":id,"name":name,"no":no,"phone":phone,"email":email,"gender":gender},
                dataType: "json",
                success: function (date) {
                    if(date==-1){
                        layer.msg("用户名重复!");
                    }else if(date==1){
                        layer.msg("修改成功");
                        var index=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                    }else{
                        layer.msg("修改失败，请稍后重试！");
                    }

                }
            });
        });
    });
</script>
</body>
</html>
